package api

import (
	"admin100/app/model/gamemodel"
	"admin100/app/service"
	"admin100/library/define"
	"admin100/library/define/defErr"
	"admin100/library/response"

	"github.com/gogf/gf/net/ghttp"
)

var PlayerMgr = &playerMgr{}

type playerMgr struct{}

// @summary 查询一个玩家
// @tags 玩家
// @produce json
// @param   platformId formData  string true "平台id"
// @param   playerName formData  string true "角色名"
// @router  /player/one [GET]
// @success 200 {object} response.JsonResponse "执行结果"
func (a *playerMgr) One(r *ghttp.Request) {
	var req gamemodel.OneReq
	if err := r.ParseQuery(&req); err != nil {
		defErr.Panic(define.Fail, err.Error())
	}

	response.JsonSuc(r, service.Tool.GetPlayerByPlatformIdAndNickname(&req))
}

// @summary 角色详细信息
// @tags 玩家
// @produce json
// @param   platformId formData  string true "平台id"
// @param   serverId formData  string true "区服id"
// @param   PlayerId formData  string true "角色ID"
// @router  /player/detail [POST]
// @success 200 {object} response.JsonResponse "执行结果"
func (a *playerMgr) Detail(r *ghttp.Request) {
	var req gamemodel.DetailReq
	if err := r.ParseForm(&req); err != nil {
		defErr.Panic(define.Fail, err.Error())
	}

	response.JsonSuc(r, service.Player.Detail(&req))
}

// @summary 角色详细信息
// @tags 玩家
// @produce json
// @param   platformId formData  string true "平台id"
// @param   account formData  string true "区服id"
// @router  /player/account-detail [POST]
// @success 200 {object} response.JsonResponse "执行结果"
func (a *playerMgr) AccountDetail(r *ghttp.Request) {
	var req gamemodel.AccountDetailReq
	if err := r.ParseForm(&req); err != nil {
		defErr.Panic(define.Fail, err.Error())
	}

	response.JsonSuc(r, service.Player.AccountDetail(&req))

}
